/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.telsoft.hms.lib.security.server;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 
 * @author VIETPH
 */
public class WsConfig {

	private Logger logger = LoggerFactory.getLogger(WsConfig.class);

	public int getSessionTimeOut() {
		int result;
		try {
			result = Integer.parseInt(getValue("session_timeout_in_minutes"));
			return result;
		} catch (MissingResourceException | NumberFormatException ex) {
			logger.info(ex.getMessage());
			return 15;
		}
	}

	public int getThreadInterval() {
		int result;
		try {
			result = Integer
					.parseInt(getValue("thread_interval_in_milliseconds"));
			return result;
		} catch (MissingResourceException | NumberFormatException ex) {
			logger.info(ex.getMessage());
			return 10 * 60 * 1000;
		}
	}

	private String getValue(String keyword) throws MissingResourceException {
		try {
			ResourceBundle bundle = ResourceBundle.getBundle("configuration");
			return bundle.getString(keyword);
		} catch (MissingResourceException ex) {
			throw ex;
		}
	}
}
